The table of contents appears in the Right Sidebar automatically when there are multiple headings in a text note.

Interaction

Global configuration

In Text Notes options, look for the Table of Contents section and configure the minimum amount of headings that need to be present in the current note in order for the table of contents to show:

Per-note configuration

Use Attributes to configure the table of contents for a particular note: